﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Wap/Shop/ShopSite.Master" AutoEventWireup="true"
    CodeBehind="CuponList.aspx.cs" Inherits="ZLCMS.Web.Wap.Member.CuponList" %>
    <%@ Register src="/Wap/Shop/Footer.ascx" tagname="Footer" tagprefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>我的优惠券</title>
    <style>
        .cuponlist .address li .right .cent span.status{background:#66CC99}
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="pages" runat="server">
    <div data-role="page" id="mypage" class="cuponlist">
        <!--S header -->
        <div data-role="header">
            <div class="head" data-ajax="false" onclick="window.history.go(-1);">
                <img src="../Shop/images/arrowLeftCom.png" />
                <h3>我的优惠券</h3>
            </div>
        </div>
        <!--S content -->
        <div role="main" class="ui-content">
            <div class="address">
                <ul class="listviewContainer">
                   <%-- <li>
                        <div class="left">
                            <div>
                                <h5>¥<span>150</span></h5>
                                <p>满150抵15</p>
                            </div>
                        </div>
                        <div class="right">
                            <div class="top">
                                <p>购自营任意产品获30元优惠券</p>
                                <span>即将开始</span>
                            </div>
                            <div class="cent">
                                <h4>满150抵15</h4>
                                <span>限自营商品</span>
                                <p>有效期2016-10-15 18:00</p>
                            </div>
                            <div class="bottom">
                                查看使用商品
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="left">
                            <div>
                                <h5>¥<span>150</span></h5>
                                <p>满150抵15</p>
                            </div>
                        </div>
                        <div class="right">
                            <div class="top">
                                <p>购自营任意产品获30元优惠券</p>
                                <span>即将开始</span>
                            </div>
                            <div class="cent">
                                <h4>满150抵15</h4>
                                <span>限自营商品</span>
                                <p>有效期2016-10-15 18:00</p>
                            </div>
                            <div class="bottom">
                                查看使用商品
                            </div>
                        </div>
                    </li>--%>
                </ul>
            </div>
        </div>
        <!--e pinpai_box-->
        <!--S footer -->
        <div data-role="footer" data-position="fixed" data-tap-toggle="false">
    
                <uc1:Footer ID="Footer1" runat="server" MenuId="M" />  
        </div>
        <!--E footer -->
    </div>
  <script src="/wap/lib/common/listviewHandler.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            var type = Number('<%=Request["type"]%>' || '4');
            if (type === 5) {
                $('title, h3').text('我的红包');
            }
            queryData(type);
        })
        function queryData(type) {
            var param = { "MemberAccount": '<%=CurrentMemberAccount %>', Type: type};
            var handler = $('.listviewContainer').listviewHandler();
            handler.initialize({
                loaderBtn: $('#btnMore'), //加载数据按钮（点击加载下一页）
                emptyHtml: '<p class="more">暂无' + (type === 5 ? '红包' : '优惠券') + '哦！</p>', //无记录时显示此html
                itemTemplate: ' <li>'
                         + ' <div class="left">'
                         + '        <div>'
                         + '            <h5>¥<span>{Amount}</span></h5>'
                         + '            {desc}'
                         + '        </div>'
                         + '    </div>'
                         + '    <div class="right">'
                         + '        <div class="top">'
                         + '            <p>{Title}</p>'
                         + '        </div>'
                         + '        <div class="cent">'
                //                         + '            <h4>满{OrderMinAmount}抵{Amount}</h4>'
                         + '            <span>{Memo}</span>{Status}'
                         + '            <p>有效期：{StartTime} 至 {EndTime}</p>'
                         + '        </div>{SupportProductHtml}'
                         + '    </div>'
                         + ' </li>', //项模板
                pageIndex: 1, //页码（从1起算）
                pageSize: 20, //页大小
                totalCount: 999, //总记录数
                itemHandler: function (data, itemTemplate, container) {//数据各项处理
                    data.SupportProductHtml = '';
                    //背景颜色
                    var bg = 'style="background:#a8a8a8;"';
                    if (data.Status == "1") {
                        var endTime = new Date(Date.parse(data.EndTime.replace(/-/g, "/")));
                        var date = new Date(Date.parse(data.StartTime.replace(/-/g, "/")));
                        if (date.getTime() < new Date().getTime() && new Date().getTime() < endTime.getTime()) {
                            data.Status = ' <span class="status">可用</span>';
                        } else {
                            if (date.getTime() > new Date().getTime()) {
                                data.Status = ' <span class="status" ' + bg + '>未生效</span>';
                            }
                            if (endTime.getTime() < new Date().getTime()) {
                                data.Status = ' <span class="status " ' + bg + '>已过期</span>';
                            }
                        }
                    }
                    if (data.OrderMinAmount) {
                        data.desc = '<p>满{OrderMinAmount}减{Amount}</p>'.format(data);
                    } else {
                        data.desc = '<p></p>';
                    }
                    if (data.Status == "9") {
                        data.Status = ' <span class="status "' + bg + '>已使用</span>';
                    }
                    if (data.RedirectUrl) {
                        data.SupportProductHtml = '<div class="bottom" onclick="location.href=\'' + data.RedirectUrl + '\'">查看适用商品</div>';
                    } else {
                        data.SupportProductHtml = '<div class="bottom" onclick="location.href=\'/wap/shop/\'">全场商品通用</div>';
                    }
                    //data.ThumbnailImg = firstThumbnail(data.ThumbnailImg);
                    //格式开始时间
                    data.StartTime = getShortDateString(data.StartTime);
                    //格式结束时间
                    data.EndTime = getShortDateString(data.EndTime);

                    return itemTemplate.format(data);
                },
                command: 'Member.LoadMemberCouponList',
                parameter: param
            });

            handler.nextPage();
        }
    </script>
</asp:Content>
